package blackhouse_servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import blackhouse_server.login_server;

@WebServlet("/login")
public class login_servlet extends HttpServlet
{
	login_server	bs	= new login_server();

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException
	{
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException
	{
		String ID = req.getParameter("id");
		String pwd = req.getParameter("pwd");
		String num = req.getParameter("num");
		int stateid = bs.info(ID, pwd, num);
		PrintWriter pt = resp.getWriter();
		if (stateid != 0)
		{
			req.getSession().setAttribute("user", ID);
		}
		pt.write(stateid + "");
	}
}
